apiVersion: apps.kubeblocks.io/v1alpha1
kind: Cluster
metadata:
  name: elsearch-cluster
  annotations:
    kubeblocks.io/extra-env: '{"mdit-roles":"master,data,ingest,transform","mode":"multi-node"}'
spec:
  # Specifies the behavior when a Cluster is deleted.
  # - `DoNotTerminate`: Prevents deletion of the Cluster. This policy ensures that all resources remain intact.
  # - `Halt`: Deletes Cluster resources like Pods and Services but retains Persistent Volume Claims (PVCs), allowing for data preservation while stopping other operations.
  # - `Delete`: Extends the `Halt` policy by also removing PVCs, leading to a thorough cleanup while removing all persistent data.
  # - `WipeOut`: An aggressive policy that deletes all Cluster resources, including volume snapshots and backups in external storage. This results in complete data removal and should be used cautiously, primarily in non-production environments to avoid irreversible data loss.
  terminationPolicy: Delete
  # Specifies a list of ClusterComponentSpec objects used to define the individual components that make up a Cluster.
  componentSpecs:
    - name: mdit
      componentDef: elasticsearch-8
      serviceVersion: 8.8.2
      serviceAccountName: kb-elsearch-cluster
      replicas: 3
      # Specifies a group of affinity scheduling rules for the Component. It allows users to control how the Component's Pods are scheduled onto nodes in the cluster.
      affinity:
        podAntiAffinity: Preferred
        topologyKeys:
          - kubernetes.io/hostname
        tenancy: SharedNode
      # Allows the Component to be scheduled onto nodes with matching taints.
      tolerations:
        - key: kb-data
          operator: Equal
          value: 'true'
          effect: NoSchedule
      # Determines whether the metrics exporter needs to be published to the service endpoint.
      disableExporter: false
      resources:
        limits:
          cpu: '0.5'
          memory: 2Gi
        requests:
          cpu: '0.5'
          memory: 2Gi
      volumeClaimTemplates:
        - name: data
          spec:
            storageClassName: "local-path"
            accessModes:
              - ReadWriteOnce
            resources:
              requests:
                storage: 10Gi
    - name: kibana
      componentDef: kibana-8
      serviceVersion: 8.8.2
      serviceAccountName: kb-elsearch-cluster
      replicas: 1
      resources:
        limits:
          cpu: '0.5'
          memory: 2Gi
        requests:
          cpu: '0.5'
          memory: 2Gi
